/* Copyright (c) 2006 YourNameHere
   See the file LICENSE.txt for licensing information. */

var Ci = Components.interfaces;
var Cc = Components.classes;
var Cr = Components.results;
var Cu = Components.utils;

// This JavaScript XPCOM component is constructed using XPCOMUtils. See
//  <https://developer.mozilla.org/en/How_to_Build_an_XPCOM_Component_in_Javascript#Using_XPCOMUtils>
//  (retrieved 2008-10-07).
Cu.import("resource://gre/modules/XPCOMUtils.jsm");

function BallStartup() {

}

BallStartup.prototype = {
  // General XPCOM component attributes
  classDescription: "Ballbet Startup Observer",
  
  classID:          Components.ID("{56FEE75B-9CBD-4abd-AB57-A2FB19EC1CC5}"),
  contractID:       "@oifile.com/ball/startup-observer;1",
  QueryInterface:   XPCOMUtils.generateQI([Ci.nsIObserver]),

  // Use XPCOMUtils to register with the category manager. The classDescription
  //  and contractID will be used during registration. For more information,
  //  see <https://developer.mozilla.org/en/Observer_Notifications> (retrieved
  //  2008-11-21).
  _xpcom_categories: [{category: "app-startup", service: true}],

  // --- nsIObserver interface functions ---

  /**
   * This function is called with aTopic set to "app-startup" when the
   *  application starts, before the first browser window is opened.
   *
   * The real initialization is done by the MAF shared modules.
   */
  observe: function(aSubject, aTopic, aData) {
    // Import the MAF shared modules and call the functions defined there.
    //  We cannot do this in the global scope, like we do for XPCOMUtils,
    //  since our resource protocol alias may not be registered at that time.
    //  See also
    //  <http://groups.google.com/group/mozilla.dev.tech.xpcom/browse_thread/thread/6a8ea7f803ac720a>
    //  (retrieved 2008-12-07).
    
    var startupObjects = {};
    Cu.import("resource://ballbet/modules/startupOjbects.jsm", startupObjects);
    startupObjects.StartupEvents.onAppStartup();
  }
};

// XPCOM component registration
var components = [BallStartup];
function NSGetModule(compMgr, fileSpec) {
  return XPCOMUtils.generateModule(components);
}